package com.juyu.miliao.api.controller;

import com.alibaba.fastjson.JSONObject;
import com.juyu.miliao.api.dao.mysql.GiftSpendDao;
import com.juyu.miliao.api.domain.GiftSpend;
import com.juyu.miliao.api.service.ReceiveGiftSortService;

import com.juyu.miliao.common.constant.ReceiveGiftSortRedisKey;
import com.juyu.miliao.common.domain.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 收礼物排行榜
 *
 * @author xuanqicheng
 * @create 2019-28-14:31
 */
@RestController
@RequestMapping("/receiveGiftSort")
public class ReceiveGiftSortController {

    @Autowired
    private ReceiveGiftSortService receiveGiftSortService;



    @GetMapping("/{page}-{pageSize}")
    public Object getGiftWall(Authentication token, @PathVariable("page") Integer page,
                              @PathVariable("pageSize") Integer pageSize,
                              HttpServletRequest request){

        if (page <= 0) {
            page = 1;
        }
        Subject subject = (Subject) token.getPrincipal();
        if (pageSize <= 0) {
            pageSize = 20;
        }

        Object object = receiveGiftSortService.getReceiveGiftSortList(page,pageSize,subject.getId());

        return object;

    }


}
